<%# $Id: edit.rhtml 568 2011-04-16 11:25:38Z toshiyuki.ando1971@gmail.com $
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>

<h2><%=l(:label_settings)%></h2>

<%= error_messages_for 'settings' %>

<% @settings = @hudson.settings %>
<% form_for @settings, :url => {:action => 'edit', :id => @project}, :html => {:method=>:put} do |setting_form| %>
<div class="box tabular">
  <p><label><%=l(:label_url)%></label>
     <%=text_field :settings, :url, :size=>50%> <%=l(:notice_hudson_url)%><br/>
     <%=check_box_tag "enable_url_for_plugin", :value => 'true' %> <%=l(:label_use_url_for_plugin)%><br/>
     <span style="display:none;" id="rect_url_for_plugin"><%=text_field :settings, :url_for_plugin, :size=>50%></span>
  </p>
  <p><label><%=l(:field_user)%></label>
     <%=text_field :settings, :auth_user, :size=>20 %></p>
  <p><label><%=l(:field_password)%></label>
     <%=password_field :settings, :auth_password, :size=>20%></p>
  <p><label><%=l(:label_get_build_details)%></label><%=check_box :settings, :get_build_details, {}, 'true'%> <%=l(:notice_get_build_details)%></p>
  <p><label><%=l(:label_show_compact)%></label><%=check_box :settings, :show_compact, {}, 'true'%></p>
  <p><label><%=l(:label_look_and_feel)%></label>
     <%=radio_button :settings, :look_and_feel, 'Hudson'%> <%=l(:label_look_and_feel_hudson)%><br>
     <%=radio_button :settings,:look_and_feel,  'Plugin'%> <%=l(:label_look_and_feel_plugin)%>
  </p>
</div>

<fieldset class="box"><legend><%=l(:label_health_report)%></legend>
  <%=l(:notice_health_report)%>
  <div id="health_report_fields" style="margin-left:10px;">
  <% @hudson.settings.health_report_settings.each do |hrs| -%>
    <% next if hrs.new_record? -%>
    <%=render :partial => 'health_report_setting', :locals => {:field_name => "health_report_settings[]", :hrs => hrs}  %>
  <% end -%>
  <% new_hrs_count = 0 -%>
  <%  @hudson.settings.health_report_settings.each do |hrs| -%>
    <% next unless hrs.new_record? -%>
    <% new_hrs_count += 1 -%>
    <%=render :partial => 'health_report_setting', :locals => {:field_name => "new_health_report_settings[#{new_hrs_count}]", :hrs => hrs}  %>
  <% end -%>
  </div>
  <span style="font-size:smaller;"><%= link_to l(:label_add_health_report), '#', :onclick => 'appender.add(); return false;' %></span>
  <script type="text/javascript">
  //<!--
  var appender = new HealthReportFieldAppender('<%=l(:notice_health_report_setting)%>', <%=new_hrs_count%>);
  //-->
  </script>
</fieldset>

<h3><%=l(:label_jobs)%></h3>

  <%=render :partial => 'joblist'%>

<p><%= submit_tag l(:button_save) %></p>
<% end %>

<h2 style="margin-top:20px;"><%=l(:label_database)%></h2>

<% form_tag({:action => 'delete_history', :id => @project}) do %>
  <%= submit_tag l(:button_delete_history) %>
<% end %>

<style type="text/css">
<!--
.health_report_explain { font-weight:bold;}
-->
</style>
<script type="text/javascript">
//<!--
<% enable_url_for_plugin = (@settings.url_for_plugin and @settings.url_for_plugin.length != 0) %>
Event.observe($('enable_url_for_plugin'), 'click', switch_state_url_for_plugin);
function switch_state_url_for_plugin(){
  display = 'none';
  if ( $('enable_url_for_plugin').checked ) { display = 'inline'; }
  $('rect_url_for_plugin').style.display = display;
}
$('enable_url_for_plugin').checked = <%=enable_url_for_plugin%>;
switch_state_url_for_plugin();
//-->
</script>

<% content_for :header_tags do %>
  <%= stylesheet_link_tag "hudson.css", :plugin => "redmine_hudson", :media => "screen" %>
  <%= javascript_include_tag 'hudson_settings', :plugin => "redmine_hudson" %>
  <%= javascript_include_tag 'job_settings_field_controller', :plugin => "redmine_hudson" %>
<% end %>
